#ifndef _SAMPLEDEBUGGER_H_
#define _SAMPLEDEBUGGER_H_

#include <assert.h>
#include "sample.h"

using namespace d_Math;

class Filter;

// ==================================================================
// A helper class for super-sampling.  Stores a set of samples for
// each pixel of the final image.

class SampleDebugger {
  
 public:

  // CONSTRUCTOR & DESTRUCTOR
  SampleDebugger(int _width, int _height, int _num_samples);

  ~SampleDebugger();

  // ACCESSORS
  int getWidth() { 
    return width; 
  }

  int getHeight() { 
    return height; 
  }

  int getNumSamples() { 
    return num_samples; 
  }

  Sample getSample(int i, int j, int n) {
    return samples[getIndex(i,j,n)]; 
  }

  // MODIFIERS
  void setSample(int x, int y, int i, d_Vec2f offset, d_Vec3f color) {
    samples[getIndex(x,y,i)].set(offset,color); 
  }
  
  // VISUALIZATION
  void renderSamples(char *samples_file, int sample_zoom);
  
private:

  int getIndex(int i, int j, int n) {
    assert (i >= 0 && i < width);
    assert (j >= 0 && j < height);
    assert (n >= 0 && n < num_samples);
    return i*height*num_samples + j*num_samples + n; 
  }

  // REPRESENTATION
  int width;
  int height;
  int num_samples;
  Sample *samples;

};

// ==================================================================

#endif
